#pragma once

#include "SwordBibleFonts.h"
#include "AutoRichEditCtrl.h"
#include "ColorMgr.h"
#include "afxcmn.h"
#include "afxdtctl.h"
#include "MyToolBar.h"
#include "SwordbibleDoc.h"
#include "afxwin.h"
#include "CustomRs.h"
#include <afxpriv.h>

// CDailyBiblePage dialog

class CDailyBiblePage : public CPropertyPage
{
	DECLARE_DYNAMIC(CDailyBiblePage)

public:
	CDailyBiblePage();
	sword::SWModule* pModuleActive;
	virtual ~CDailyBiblePage();

	inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
	CString ReadingDate;
	CString Data;
	void Delete();
	void CreateBlankRecord();
	void AddNew();
	void UpdateBoundData();
	void GenerateError(HRESULT hr, PWSTR pwszDescription);
	BOOL CreateDB(); 
	void CreateDatabaseX();

	void AddPlanNames();  /* Add the reading plans (database tables) to planNames array */
	void SelectTable(CString tableName); /* Select a different reading plan   */
	void AddTable(CString TableName, CString C1, CString C2);    /* Add a new reading plan */
	void DeleteTable(CString TableName); /* Delete a reading plan */
	void SaveReadingData(CString date, CString readingdata);  /* save the entry to Data.mdb database or create new if DNE */
	void DeleteReadingData(CString date); /* Delete reading data for a particular date */
    CString GetReadingData(CString date); 	/* Queries the database to retrieve a string of verses for given date*/


// Dialog Data
	enum { IDD = IDD_DAILYBIBLEPAGE };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	CMyToolBar m_wndFormatBar;
	bool GetAppDirectory( CString& strAppDir );
	CString path;
	DECLARE_MESSAGE_MAP()


public:

	virtual BOOL OnInitDialog();
	void PopulateTree();
	void showText();
	void AddHeadings(CString& Text);   // add pre-verse headings to the beginning of each verse
	BOOL OnToolTipNotify(UINT id, NMHDR *pNMHDR,   LRESULT *pResult);

	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnPrint();
	afx_msg void OnPreviousDate();
	afx_msg void OnNextDate();
	afx_msg void OnSelectAll();
	afx_msg void OnCopy();
	afx_msg void OnSelCalendar(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnSelchangeTree(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnShowVersions();
	afx_msg void OnZoom();
	afx_msg void OnUpdateZoom(CCmdUI *pCmdUI);
	afx_msg void OnEnMsgfilter(NMHDR *pNMHDR, LRESULT *pResult);

	CMonthCalCtrl DBCalendarCtrl;
	CAutoRichEditCtrl m_rich;
	CTreeCtrl DBTreeCtrl;
	CImageList m_image; // member variable to hold the image list

private:
	int active;
	CString timeKey;
	CString timeFormatted;
	CStringArray planNames;
	CString plan;

	void RefreshBoundData();
	CCustomRs m_rsRecSet;
	CString m_strCmdText;
	CString m_strConnection;
	IADORecordBinding* m_piAdoRecordBinding;
	_RecordsetPtr m_pRs;
	BOOL IsAppData;
	ADOX::_CatalogPtr m_pCatalog;


private:
		void ZoomText();
		void OnRightButtonDown();
	
	
	
		
};
